import java.util.Scanner;
import java.io.*;

public class ReadFileTwice{
  public static void main(String[] args) throws IOException{
    FileInputStream instream = new FileInputStream("myinput.txt");
    
    Scanner fscanner = new Scanner(instream);
                                   
    double max = 0, grade;
    int count = 0;
    
    if(fscanner.hasNextDouble())
       max = fscanner.nextDouble(); // Assume the first value is the maximum
    else{
     System.out.println("Error: The next value in file myinput.txt is not convertible to double");
     System.exit(1);
    }
    
    while(fscanner.hasNextDouble()){
       grade = fscanner.nextDouble();
       if(grade > max)
          max = grade;
    }
    
    fscanner.close();
    
    instream = new FileInputStream("myinput.txt");
    fscanner = new Scanner(instream);
    
     while(fscanner.hasNextDouble()){
       grade = fscanner.nextDouble();
       if(grade == max)
          count++;
    }
     
    System.out.printf("The frequency of the maximum grade %.2f is %d%n", max, count);
    fscanner.close();
  }
}
